/*
 *   Copyright 2023 <a href="mailto:asialjim@hotmail.com">Asial Jim</a>
 *
 *   Licensed under the Apache License, Version 2.0 (the "License");
 *   you may not use this file except in compliance with the License.
 *   You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 *   Unless required by applicable law or agreed to in writing, software
 *   distributed under the License is distributed on an "AS IS" BASIS,
 *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *   See the License for the specific language governing permissions and
 *   limitations under the License.
 */
package com.asialjim.encommunicate.rsa.filter;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * 检查器：判断应用的通讯是否需要加密
 *
 * @author Copyright © <a href="mailto:asialjim@hotmail.com">Asial Jim</a>   Co., LTD
 * @version 1.0
 * @since 2023/2/28, &nbsp;&nbsp; <em>version:1.0</em>, &nbsp;&nbsp; <em>java version:17</em>
 */
public interface ApplicationEnDecryptChecker {
    Logger log = LoggerFactory.getLogger(ApplicationEnDecryptChecker.class);
    ApplicationEnDecryptChecker DEFAULT = new Default();

    /**
     * 判断请求是否需要加密
     * @return {@link Boolean 请求是否需要加密}
     * @since 2023/2/28
     */
    default boolean reqEncNeed(String appid){
        log.warn("默认对应用：{} 请求不启用加密",appid);
        return false;
    }

    /**
     * 判断响应是否需要加密
     * @return {@link Boolean 响应是否需要加密}
     * @since 2023/2/28
     */
    default boolean resEncNeed(String appid){
        log.warn("默认对应用：{} 响应不启用加密", appid);
        return false;
    }

    class Default implements ApplicationEnDecryptChecker{

        @Override
        public String toString() {
            return "Default ApplicationEnDecryptChecker";
        }
    }
}